解决:
<id name="id">
<column name="id" sql-type="int(11)"/>
<generator class="native"/> //加上自动生成
</id>
2.org.hibernate.AssertionFailure: null id in com.base.program.entity.Program entry (don't flush the Session after an except)
解决:
字段不够长,给ID指定长度
@Id
@Column(name = "id", nullable = false,length = 11)
@GeneratedValue(strategy=GenerationType.AUTO)
private int id;
3.org.hibernate.engine.jndi.JndiException: Error parsing JNDI name
去掉hibernate.cfg.xml里的 name 属性
javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of cc.www.hibernateproject.model.Student.fenshu
解决方法1:该bean 中相应字段int 改为Integer
解决方法2:数据库中相应字段默认不为null